<?php
namespace SidToken\Model;


use Think\Model;

/**
 * 计划任务模块
 * Class QueueLogModel
 * @package TaskCenter\Model
 */
class QueueLogModel extends Model
{
    public function addQueueLog($name, $etime)
    {
        $data = array(
            'name' => $name,
            'ctime' => time(),
            'status' => 1,
            'etime' => $etime
        );
        return $this->add($data);
    }

    /**
     * 检查任务是否今日已经执行
     * @param $name
     * @return bool
     */
    public function checkIsRunToday($name)
    {
        $last = $this->where("name='{$name}'")->order("ctime DESC")->limit(1)->find();
        if ($last) {
            if (strtotime(date("Ymd", $last['ctime'])) >= strtotime(date("Ymd"))) {
                return true;
            }
        }
        return false;
    }
}